﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MATLAB;
using MatlabTestLib;
using MatlabTestLibNative;
using MathWorks.MATLAB.NET.Arrays;
using System.Diagnostics;

namespace MatlabTest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

        }

        public void test()
        {
            // 实例化MATLAB dll 指定类的对象,实例化对象需要2秒的时间
            MatlabTestLib.MatlabTest m = new MatlabTestLib.MatlabTest();
            int num1 = 2;
            int num2 = 3;
            // 调用方法计算两数的乘积并接收返回值
            MWArray result = m.myfun((MWNumericArray)num1,(MWNumericArray)num2);
            // 第一种转换和取值方法 Array 因为返回的是一个矩阵，也就是二维数组，所以GetValue要用x y两个坐标
            Array result2 = result.ToArray();
            Trace.WriteLine(result2.GetValue(0, 0));
            // 第二种转换和取值方法ToString
            Trace.WriteLine(result.ToString());
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ColourConvert.LabToRgb(80,40,100);
        }
    }
}
